package cn.com.aiouyi.dao.impl;

import cn.com.aiouyi.dao.BusinessExceptionLogDao;
import cn.com.aiouyi.dao.PluginConfigDao;
import cn.com.aiouyi.entity.ArticleClass;
import cn.com.aiouyi.entity.BusinessExceptionLog;
import cn.com.aiouyi.entity.PluginConfig;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import javax.persistence.NoResultException;

/**
 * Dao - 插件配置
 * @author tommy
 *
 */
@Repository("pluginConfigDaoImpl")
public class PluginConfigDaoImpl extends BaseDaoImpl<PluginConfig, Long> implements PluginConfigDao{

    @Override
    public PluginConfig findByPluginId(String pluginId) {
        if (StringUtils.isEmpty(pluginId)) {
            return null;
        }
        try {
            String jpql = "select pluginConfig from PluginConfig pluginConfig where pluginConfig.pluginId = :pluginId";
            return entityManager.createQuery(jpql, PluginConfig.class).setParameter("pluginId", pluginId).getSingleResult();
        } catch (NoResultException e) {
            return null;
        }
    }
}
